Jump to content

Module:Kk-translit

Frae Wikipedia, the free beuk o knawledge
--[[
Transliteration for Kazakh.
]]
local M={}

local tt={
          ["ү"]="ü",['Ү']='Ü',   ["т"]="t",['Т']='T', ["р"]="r",['Р']='R',   ["ф"]="f",['Ф']='F', ["ө"]="ö",['Ө']='Ö',
          ["ю"]="yu",['Ю']='Yu', ["ш"]="ş",['Ш']='Ş', ["ь"]="ʹ",['Ь']='ʹ',   ["ъ"]="ʺ",['Ъ']='ʺ', ["н"]="n",['Н']='N', 
          ["п"]="p",['П']='P',   ["й"]="y",['Й']='Y', ["л"]="l",['Л']='L',   ["з"]="z",['З']='Z', ["е"]="e",['Е']='E', 
          ["г"]="g",['Г']='G',   ["б"]="b",['Б']='B', ["у"]="w",['У']='W',   ["с"]="s",['С']='S', ["х"]="h",['Х']='H',
          ["ч"]="ç",['Ч']='Ç', ["щ"]="şç",['Щ']='Şç', ["я"]="ya",['Я']='Ya', ["ы"]="ı",['Ы']='I', ["э"]="e",['Э']='E', 
          ["м"]="m",['М']='M',   ["о"]="o",['О']='O', ["и"]="ï",['И']='Ï', ["ё"]="yo",['Ё']='Yo', ["ж"]="j",['Ж']='J',
          ["к"]="k",['К']='K',   ["д"]="d",['Д']='D', ["в"]="v",['В']='V', ["ц"]="ts",['Ц']='Ts', ["а"]="a",['А']='A',
          ["ң"]="ñ",['Ң']='Ñ',   ["ә"]="ä",['Ә']='Ä', ["э"]="é",['Э']='É', ["ұ"]="u",['Ұ']='U', ["қ"]="q",['Қ']="Q",
          ["ғ"]="ğ",['Ғ']='Ğ',   ["і"]="i",['І']='I'
};
function M.tr(text)--translit any words or phrases
    if type(text) == "table" then text = text.args[1] end
    
    text = mw.ustring.gsub(
            text,   "([АОӨӘУҰЫЕЯЁЮИЕІаоөәуұыэяёюиеіъь%A][́̀]?)([Ее])",
            function(a,e) return a..(e=='е' and 'ye' or 'Ye') end
        ):gsub("^Е",'Ye'):gsub("^е",'ye');
    return (mw.ustring.gsub(text, '.', tt))
end
return M